#include "tcpclient.h"
#include <QHostAddress>
tcpclient::tcpclient(QString ip,int port,QObject *parent) : QObject(parent)
{
    m_socket=new QTcpSocket(this);
    arr.clear();
    m_ip=ip;
    m_port=port;
}

tcpclient::~tcpclient()
{
    m_socket->close();
    delete m_socket;
}

void tcpclient::TcpConnect()
{
    m_socket->connectToHost(QHostAddress(m_ip),m_port);
}

void tcpclient::send()
{
    TcpConnect();
    m_socket->write(arr.data());
}

void tcpclient::write(char *data)
{
      arr.append(data);
}

void tcpclient::write(const char *data)
{
    arr.append(data);
}

void tcpclient::write(QString str)
{
    arr.append(str);
}

void tcpclient::write(QByteArray data)
{
    arr.append(data);
}

void tcpclient::clear()
{
    arr.clear();
}

void tcpclient::clearnetwork()
{
    Receiving.clear();
}
